package lab02.test11;

public class Square extends Rectangle {


    double diagonal;

    @Override
    public double perimeter() {
        double perimeter = 2 * (width + width);
        return super.perimeter();
    }

    @Override
    public double area() {
        double area = width * width;
        return super.area();
    }

    public double diagonal() {
        return width * Math.sqrt(2);
    }



    @Override
    public void printMyWay() {
        System.out.println("正方形的边长为：" + width);
        System.out.println("正方形的周长为：" + perimeter());
        System.out.println("正方形的面积为：" + area());
        System.out.println("正方形的对角线为：" + diagonal());
    }
}
